<!DOCTYPE html>
<html>
<head>
<title></title> <@h.head />
<script type="text/javascript" src="${path}/static/plugins/lhgdialog/lhgdialog.min.js"></script>
<style type="text/css">
body {
	padding-bottom: 40px;
}

@media ( max-width : 980px) {
	.navbar-text.pull-right {
		float: none;
		padding-left: 5px;
		padding-right: 5px;
	}
}
</style>
</head>
<body>
	<div class="definewidth m20">
		<a class="btn btn-default" href="${path}/sysrole/add"><i class="fa fa-plus fa-lg"></i> 新增</a>
	</div>
	
	<table class="table table-bordered table-hover definewidth m10">
		<thead>
			<tr>
				<th onclick="checkAll();"><input type="checkbox" id="checkAll">全选</th>
				<th>角色ID</th>
				<th>名称</th>
				<th>描述</th>
				<th>修改操作</th>
				<th>删除操作</th>
				<th>权限配置</th>
			</tr>
		</thead>
		<tbody>
			<#list list as u>
			<tr class="">
				<td><input type="checkbox" name="checkbox" value="id=${(u.id)!''}"></td>
				<td>${(u.id)!""}</td>
				<td>${(u.name)!""}</td>
				<td>${(u.remark)!""}</td>
				<td><a href="${path}/sysrole/update?id=${u.id}">修改</a></td>
				<td><a href="javascript:void(0)" onclick="deleteChecked('${u.id}');">删除</a></td>
				<td><a href="javascript:void(0)" onclick="setRight('${u.id}');">配置</a></td>
			</tr>
			</#list>
		</tbody>
	</table>
	<@h.foot />
	<script type="text/javascript">
		function checkAll() {
			if ($("#checkAll").attr("checked") == "checked") {
				$("[name='checkbox']").attr("checked", 'true');//全选
			} else
				$("[name='checkbox']").removeAttr("checked");//取消全选
		}
		
		function deleteChecked(id) {
			$.dialog({
				title: '提示',
				icon: 'alert.gif',
			    content: '确认删除？',
			    width: 180,
			    cancel: true,
			    cancelVal: '取消',
			    ok: function(){
			    	var checkurl = "${path}/sysuser/checkrole/" + id;
					$.get(checkurl, function(data) {
						var data = eval('(' + data + ')');
						if (data.status == "200") {
							window.location.href = '${path}/sysrole/delete?id=' + id;
						} else {
							$.dialog({
								title: '提示', icon: 'error.gif', content: data.error,
							    ok: function(){}
							});
						}
					});
			    }
			});
		}
		
		function setRight(id){
			$.dialog({
			    lock: true,
			    title: '权限分配',
			    background: '#FFF', /* 背景色 默认的遮罩背景色为:#DCE2F1浅蓝护眼色 */
			    opacity: 0.5,       /* 透明度 */
			    content: 'url:${path}/sysrole/right?id=' + id,
			    height: 300,
			    ok: function () {
			    	return false;
			    },
			    cancel: true
			});
		}
	</script>
</body>
</html>
